<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

?>
<table class="tbi" style="margin: 0px 0px 0px 8px;width: 696px;">
    <?
    $page=1;
    if(isset ($_REQUEST["page"])){
        $page=$_REQUEST["page"];
    }
    if(isset ($_REQUEST["subject"])){
        $artistdata=artistModule::getAlbums_search($_REQUEST["key"],$_REQUEST["bugs"],$_REQUEST["subject"],($page-1),20);
    }else{
        $artistdata=artistModule::getAlbums(($page-1),20);
    }
    if($artistdata==null){
        echo "<tr><td colspan=6>Data is empty.</td></tr>";
    }else{
        foreach ($artistdata as $artistrow){
            ?>
            <tr>
                <td class="tdkeyalbum" style="width: 40px"><?=isset($artistrow["key"])?$artistrow["key"]:""?></td>
                <td class="tdbugsalbum" style="width: 80px"><?=isset($artistrow["key_bugs"])?$artistrow["key_bugs"]:""?></td>
                <td class="tdsubjectalbum" style="width: 200px"><?=isset($artistrow["subject"])?$artistrow["subject"]:""?></td>
                <td class="tdinsertalbum" style="width: 120px"><?=isset($artistrow["insert"])?$artistrow["insert"]:""?></td>
                <td class="tdupdatealbum" style="width: 120px"><?=isset($artistrow["update"])?$artistrow["update"]:""?></td>
                <td class="tdactionalbum"><a href="javascript:void(0);">Edit</a></td>
            </tr>
            <?
        }
    }

    ?>
            <tr>
                <td colspan="6" style="text-align: center;">
                    <?
                    if(isset ($_REQUEST["subject"])){
                        $npages=artistModule::getAlbums_search_numpage($_REQUEST["key"],$_REQUEST["bugs"],$_REQUEST["subject"],20);
                    }else{
                        $npages=artistModule::getAlbums_search_numpage('','','',20);
                    }
//                    $nshow=10;
//                    for ($i=1;$i<=$npages;$i++){
//                        $nshow--;
//                        if($nshow<0){echo "...";break;}
//                        echo "<a href='#i' class='JO_pagesi".(($i==$page)?" pageactive":"")."'>$i</a>";
//                    }
                    if($npages>1){

                        if($page-5>1) echo "...";
                        for($i=$page-5;$i<=($page+5);$i++){
                            if($i>0 && $i<=$npages){
                            echo "<a href='javascript:void(0);' class='JO_pagesi".(($i==$page)?" pageactive":"")."'>$i</a>";
                            }
                        }
                        if($page+4<$npages) echo "...";


                    }
                    ?>
                </td>
            </tr>
</table>